import { fileURLToPath, URL } from 'node:url'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx()
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    hmr: true,
    proxy: {
      '/examples': 'https://echarts.apache.org',
      '/os': 'https://gw.alipayobjects.com',
      '/api': {
        target: 'http://localhost:3000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '/g2Api': {
        target: 'https://assets.antv.antgroup.com/g2',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/g2Api/, ''),
      },
      '/g6Api': {
        target: 'https://gw.alipayobjects.com/os',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/g6Api/, ''),
      },
    }
  },
  css: {
    // 预处理配置项
    preprocessorOptions: {
      less: {
        math: "always"
      }
    }
  }
})
